import pygame
from game import Game


class Image:
    def __init__(self, img, x: int, y: int, w: int, h: int, alpha_value: int):
        self.load_image = pygame.image.load(img)
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.rect = pygame.Rect(self.x, self.y, self.w, self.h)  # 修正了这里
        self.image = pygame.transform.scale(self.load_image, (self.w, self.h))  # 修正了这里
        self.alpha_value = alpha_value  # 这里的值可以是 0 到 255 之间的整数
        self.image.set_alpha(self.alpha_value)

    def display_image(self):
        Game.window.blit(self.image, (self.rect.x, self.rect.y))  # 修正了这里

    def display_image_star(self, x: int, y: int, w: int, h: int, alpha_value: int):
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.rect = pygame.Rect(self.x, self.y, self.w, self.h)  # 修正了这里
        self.image = pygame.transform.scale(self.load_image, (self.w, self.h))  # 修正了这里
        self.alpha_value = alpha_value  # 这里的值可以是 0 到 255 之间的整数
        self.image.set_alpha(self.alpha_value)
        Game.window.blit(self.image, (self.rect.x, self.rect.y))  # 修正了这里
